package com.company.steamAPI.list去重;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ylr
 * @version 1.0.0
 * @ClassName Demo.java
 * @Description TODO
 * @createTime 2021年10月09日 21:17:00
 */
public class Demo {
    public static void main(String[] args) {
        int[] list = new int[]{1,2,2,2,3,4,5,5,5,6,7};
        List<Integer> list1 = Arrays.stream(list).boxed().collect(Collectors.toList());
        /**
         * LinkedHashSet
         */
        LinkedHashSet<Integer> set = new LinkedHashSet<Integer>(list1);
        ArrayList<Integer> list2 = new ArrayList<>(set);


        list2.stream().forEach(System.out::print);


        /**
         * --------------方法二-------------------------
         */
        System.out.println("\n--------------方法二-------------------------");
        int[] l = new int[]{1,2,2,2,3,4,5,5,5,6,7};
        List<Integer> list3 = Arrays.stream(l).boxed().distinct().collect(Collectors.toList());
        list3.stream().forEach(System.out::print);


    }
}
